package com.ars.common.dao.activity;

import com.ars.common.beans.Active.Active;
import com.ars.common.utils.DBUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class FindCollegeActive {
    public static ArrayList<Active> findActive(String id) throws SQLException {


        String sql = "select * from active where creatorID like ? ";

        PreparedStatement ps = DBUtil.getConnection().prepareStatement(sql);
        ps.setString(1, "%____"+id+"%");


        ResultSet rs = ps.executeQuery();

        ArrayList<Active> ActiveList = new ArrayList<>();

        while (rs.next()) {
            Active active = new Active();
            active.setId(rs.getInt("id"));
            active.setName(rs.getString("name"));
            active.setType(rs.getString("type"));
            active.setBeginTime(rs.getString("beginTime"));
            active.setEndTime(rs.getString("endTime"));
            ActiveList.add(active);
        }

        return ActiveList;
    }
}
